import request from '@/utils/request'

//获取用户列表

export function getRole() {
    return request({
        url: 'role',
        method: 'get',
        data: {
        },
        headers: {}
    })
}
export function getUser(current,size,value) {

    return request({
        url: 'user'+'?current='+current+'&size='+size+'&role='+value.role+'&stuClass='+value.stuClass
        +'&name='+value.name+'&uid='+value.uid,
        method: 'get',
        data: {
        },
        headers: {}
    })
}

// /user/add单个添加学生
export function postUserAdd(value) {

    return request({
        url: 'user/add',
        method: 'post',
        data: {
            "uid": value.uid,
            "stuName": value.stuName,
            "stuClass": value.stuClass,
            "id": value.id,
            "gender": value.gender,
        },
        headers: {}
    })
}

export function getUserModle(){
    return request({
        url: 'user/excel',
        method: 'get',
        data: {
        },
        responseType: 'blob'
    })
}

export function postUserBatchAdd(fd) {

    return request({
        url: 'user/batchAdd',
        method: 'post',
        data: fd,
        headers: {},
        headers: {'Content-Type': 'multipart/form-data'}
    })
}

///user删除用户
export function DElUser(ids){
    return request({
        url:'user',
        method: 'delete',
        data: {studentIds:ids},
        headers: {},
    })
}

//重置密码
export function getUserReset(uid){
    return request({
        url:'user/reset'+'?uid='+uid,
        method: 'get',
        data:{},
        headers: {},
    })
}


export function getRoleMenuList(){
    return request({
        url:'role/getMenuList',
        method: 'get',
        data:{},
        headers: {},
    })
}


export function getRoleMenus(roleId){
    return request({
        url:'role/getMenus'+'?roleId='+roleId,
        method: 'get',
        data:{},
        headers: {},
    })
}
export function PutRoleMenus(roleId,ids){
    return request({
        url:'role'+'?roleId='+roleId,
        method: 'put',
        data:{menuIds:ids},
        headers: {},
    })
}

export function postBanRole(roleId){
    return request({
        url:'role'+'?roleId='+roleId,
        method: 'delete',
        data:{},
        headers: {},
    })
}

export function postEnableRole(roleId){
    return request({
        url:'role/enableRole'+'?roleId='+roleId,
        method: 'get',
        data:{},
        headers: {},
    })
}


export function getUserRole(uid){
    return request({
        url:'user/getRole'+'?uid='+uid,
        method: 'get',
        data:{},
        headers: {},
    })
}
export function postEditUserRole(uid,rolelist){
    return request({
        url:'user/reviseRole'+'?uid='+uid,
        method: 'post',
        data:{roleIds:rolelist},
        headers: {},
    })
}

export function postAddRole(roleform){
    return request({
        url:'role/addRole',
        method: 'post',
        data:{
            "roleName": roleform.roleName,
            "description": roleform.description,
            "isDefault": roleform.isDefault,
            "isAvailable": roleform.isAvailable,
            "menuIdList": roleform.menuIdList
        },
        headers: {},
    })
}